<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  *{
    margin: 0px;
    padding: 0px;
  }
  input{
    margin: 30px 0px 0px 30px;
  }
  hr{
    margin: 10px 0px 5px 0px;
  }
  .box{
    width: 500px;
    height: 300px;
    /* background-color: pink; */
    margin-left: 30px;
  }
</style>
<body>
  <!-- 输入框 -->
  <input type="text">
  <!-- 搜索 -->
  <button>搜索</button>
  <hr>
  <!-- 历史记录 box -->
  <div class="box"></div>
</body>
<script>
  var inp = document.querySelector('input');
  var but = document.querySelector('button');
  var box = document.querySelector('.box');
  var index = 1;
  but.onclick = function(){
    var value = inp.value;
    // 本地存储
    localStorage.setItem(`num${index}`,value);
    index++;
    var p = document.createElement('p');
    p.innerText = value;
    box.append(p);
  }
  console.log(localStorage);
</script>
</html>